<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui"%>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>基础档案资料列表</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<script type="text/javascript">
	var grid = null;
	$(function () {
		var _url = '<%=path%>/basic/archivesinfo/initList.do' ;
	    $("#ligergrid1").ligerGrid({
	    	url: _url,
	    	method : 'get',
	        columns: [
  	            { display: '操作', width: 230 ,height:'100px', align:'center',
	            	render: function (rowdata, rowindex, value){
	            		var h='<a href="javascript:showDetail(';
	            		h+="'"+rowdata.id+"'";
	                    h+=')">查看</a>';
	                    h+=' | ';
	                    h+='<a href="javascript:modifyRow(';
	            		h+="'"+rowdata.id+"'";
	                    h+=')">修改</a>';
	                    h+=' | ';
	                    h+='<a href="javascript:deleteRow(';
	            		h+="'"+rowdata.id+"'";
	                    h+=')">作废</a>';
	                	return h;
	            	}
	            },
	            { display: '权证名称', name: 'warrNm', align:'center', width: 165 },
	            { display: '权证类别', name: 'warrTypeNM', align:'center', width: 160 },
	            { display: '权证级别', name: 'warrLvNM', align:'center', width: 160 },
	            { display: '客户类型', name: 'custTypeNM', align:'center', width: 160 },
	            { display: '婚姻情况', name: 'warStsNM',align:'center', width: 160 },
	        ],
	        pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'100%',
	        heightDiff:-2,
	        rownumbers:true,
	        fixedCellHeight:false
	    });
	    grid = liger.get("ligergrid1");
	    grid.setHeight(400);
	    $("#searchBar").ligerForm();
	
	    $("#searchBtn").click(function(event) {
	         var form = new liger.get("searchBar");
	         var data = form.getData();
	         for (name in data){
	            grid.setParm(name,data[name]);
	         };
	        grid.reload();
	    });
	    
	});
  	
	//删除数据
	function deleteRow(_id){
		if(!_id)return;
		$.ligerDialog.confirm('确定删除吗?', function (flag) {
			if(flag == false)return;
			var wait_dialog;
			$.ajax({
				type: 'post',
				dataType: 'json',
				data:{id: _id},
				url: '<%=path%>/basic/archivesinfo/remove.do?id='+_id,
				beforeSend: function(){
			          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
			     },
				success:function(msg){
					wait_dialog.close();
					 if(msg.success == 1){
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
						 grid.reload();
					 }else{
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
					 }
				}
			});
		});
	}
  	
  	//修改方法
  	function modifyRow(_id){
        $.ligerDialog.SQopen({
            cls: 'noBorder_Dialog',
            width: 600,
            height:240,
            title : '修改基础档案资料',
            url:'<%=path%>/basic/archivesinfo/toAddPage.do?id='+_id,
            // 自定义buttons的时候 不要设置 fixButtons: true
            buttons: [{
	                text: "保存", type: 'ok', cls: 'l-dialog-btn-ok', 
	                onclick: function (item, Dialog) {
	                    //在子页面里绑定 frameElement.dialog.onOk = function () {}
	                    if (Dialog.onOk) {
	                    	Dialog.onOk();
	                    }
        				grid.reload();
	                }
            		}, {
                    text: "关闭", type: 'cancel', cls: 'l-dialog-btn-no', 
                    onclick: function (item, Dialog) {
                        //在子页面里绑定 frameElement.dialog.onCancel = function () {}
                        if (Dialog.onCancel) Dialog.onCancel();
                    }
                }
            ]
        });
  	}
	
	//新增
	function add(){
		$.ligerDialog.SQopen({
            cls: 'noBorder_Dialog',
            width: 600,
            height:240,
            title : '新增基础档案资料',
            url:'<%=path%>/basic/archivesinfo/toAddPage.do',
            // 自定义buttons的时候 不要设置 fixButtons: true
            buttons: [{
                    text: "保存", type: 'ok', cls: 'l-dialog-btn-ok', 
                    onclick: function (item, Dialog) {
                        //在子页面里绑定 frameElement.dialog.onOk = function () {}
                        if (Dialog.onOk) {
                        	Dialog.onOk();
                        }
                        grid.reload();
                        
                    }
                }, {
                    text: "取消", type: 'cancel', cls: 'l-dialog-btn-no', 
                    onclick: function (item, Dialog) {
                        //在子页面里绑定 frameElement.dialog.onCancel = function () {}
                        if (Dialog.onCancel) Dialog.onCancel();
                    }
                }
            ]
        });
	}
	
	//查看详情
	function showDetail(_id){
		$.ligerDialog.SQopen({
            cls: 'noBorder_Dialog',
            width: 500,
            height:240,
            title : '基础档案资料详情',
            url:'<%=path%>/basic/archivesinfo/toDetailPage.do?id='+_id,
            // 自定义buttons的时候 不要设置 fixButtons: true
            buttons: [ {
                    text: "关闭", type: 'cancel', cls: 'l-dialog-btn-no', 
                    onclick: function (item, Dialog) {
                        //在子页面里绑定 frameElement.dialog.onCancel = function () {}
                        if (Dialog.onCancel) Dialog.onCancel();
                    }
                }
            ]
        });
	}
	
	//清空按钮事件
	function clearBtn(){
		 $("#resetBtn").click();  //重置 input-text
		 var form = new liger.get("searchBar");
		 form.setData({  //重置select等特殊表单
		    "warrNm":"",
		    "warrTypeCd":" ",
		    "warrLv":" ",
		  });
	}
	
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}
	
</script>

<body class="iframeBody">
	<div class="Wrapper">
		<div class="searchArea">
			<form id="searchBar">
				<div class="fieldset1 clearFix">
					<div class="fieldBox">
						<div class="label">权证名称</div>
						<div class="field">
							<input name="warrNm" id="warrNm" type="text" class="ui-textbox" value="">
						</div>
					</div>
					<div class="fieldBox">
						<div class="label">权证类别</div>
						<div class="field">
							<select name="warrTypeCd" id="warrTypeCd" data-value=" ">
								<option value=" " selected = "selected">请选择</option>
								<option value="1">合同资料</option>
								<option value="2">承租人资料</option>
								<option value="3">权证资料</option>
								<option value="4">其他资料</option>
								<option value="5">担保人资料</option>
							</select>
						</div>
					</div>
					<div class="fieldBox">
						<div class="label">权证级别</div>
						<div class="field">
							<select name="warrLv" id="warrLv" data-value=" ">
								<option value=" " selected = "selected">请选择</option>
								<option value="1" >A（公开）</option>
								<option value="2">B（保密）</option>
							</select>
						</div>
					</div>
					<div class="clearFix"></div>
					<div class="btnsBox formBtns notRight">
						<span id="searchBtn" class="sq-button-round">查询</span>
						<span id="clearBtn" class="sq-button-round" onclick="clearBtn();">清空</span>
						<span id="addBtn" class="sq-button-round" onclick="add();">添加</span>
						<input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide" />
					</div>
				</div>
			</form>
		</div>
	</div>
	<div id="ligergrid1" class="sq-grid"></div>


</body>
</html>